package net.zdreamer.geracomium.adapter;

import java.util.List;

import net.zdreamer.geracomium.entity.DateGirdInfos.DateGirdInfo;
import net.zdreamer.geracomium.utils.tools_utils.ViewHolder;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.geracomium.R;

public class DateGridAdapter extends MyBaseAdapter<DateGirdInfo> implements
        OnItemClickListener {
    //private GridViewAdapter gridadpter;
    public DateGridAdapter(Context context, List<DateGirdInfo> list, int res) {
        super(context, list, res);
    }

    @Override
    protected View getView(int position, View convertView, ViewGroup parent,
                           DateGirdInfo value) {
        TextView reserve_time = ViewHolder.get(convertView, R.id.reserve_time);
        ImageView date_back = ViewHolder.get(convertView, R.id.data_back);
        reserve_time.setText(value.date);
        if (position == 0 || position == 1) {
            // reserve_time.setBackgroundColor(0xffffffff);
            reserve_time.setBackgroundResource(R.drawable.shape_circle);
            //  position = 2;
        }
        if (position == 2) {
            date_back.setVisibility(View.VISIBLE);
            reserve_time.setTextColor(0xffffffff);
        }
        return convertView;
    }

    @Override
    public void onItemClick(AdapterView<?> arg0, View convertView,
                            int position, long arg3) {
        for (int i = 2; i < 5; i++) {
            if (position == i) {
                ImageView date_back = (ImageView) arg0.getChildAt(i)
                        .findViewById(R.id.data_back);
                TextView reserve_time = (TextView) arg0.getChildAt(i)
                        .findViewById(R.id.reserve_time);
                //   gridadpter.notifyDataSetChanged();
                date_back.setVisibility(View.VISIBLE);
                reserve_time.setTextColor(0xffffffff);
            } else {
                ImageView date_back = (ImageView) arg0.getChildAt(i)
                        .findViewById(R.id.data_back);
                TextView reserve_time = (TextView) arg0.getChildAt(i)
                        .findViewById(R.id.reserve_time);
                //   gridadpter.notifyDataSetChanged();
                date_back.setVisibility(View.GONE);
                reserve_time.setTextColor(0xff999999);
            }
        }

    }

}
